package com.taotao.rest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbItem;
import com.taotao.pojo.TbItemDesc;
import com.taotao.pojo.TbItemParamItem;
import com.taotao.rest.service.ItemService;

@RequestMapping("/item")
@Controller
public class ItemController {
	@Autowired
	private ItemService itemService;

	/**
	 * 发布获取商品基本信息的服务
	 * 
	 * @param itemId
	 * @return
	 * @author: JSJ
	 */
	@ResponseBody
	@RequestMapping("/base/{itemId}")
	public TaotaoResult getItemById(@PathVariable long itemId) {
		TbItem item = itemService.getItemById(itemId);
		return TaotaoResult.ok(item);
	}

	/**
	 * 发布获取商品描述服务
	 * 
	 * @param itemId
	 * @return
	 * @author: JSJ
	 */
	@ResponseBody
	@RequestMapping("/desc/{itemId}")
	public TaotaoResult getItemDescById(@PathVariable long itemId) {
		TbItemDesc itemDesc = itemService.getItemDescById(itemId);
		return TaotaoResult.ok(itemDesc);
	}

	/**
	 * 发布商品规格参数服务
	 * 
	 * @param itemId
	 * @return
	 * @author: JSJ
	 */
	@ResponseBody
	@RequestMapping("/param/{itemId}")
	public TaotaoResult getItemParamItemByItemId(@PathVariable long itemId) {
		TbItemParamItem itemParam = itemService
				.getItemParamItemByItemId(itemId);
		return TaotaoResult.ok(itemParam);
	}
}
